const text = document.getElementById('showCode')
const editor = CodeMirror.fromTextArea(text, {
  lineNumbers: true,
  mode: 'python',
  key: 'value',
  value: '# hello'
})
editor.setSize('600px', '600px')

// editor与文本框互传文本
editor.on('keyup', function () {
  text.value = editor.getValue()
})

setInterval(function () {
  if (document.activeElement.tagName !== 'TEXTAREA') {
    editor.setValue(text.value)
  }
}, 100)
